CREATE TABLE [dbo].[tb_TiposDeTenencia]
(
[idTipoDeTenencia] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updateTipoTenencia] ON [dbo].[tb_TiposDeTenencia] 
FOR UPDATE
AS

if (update(idTipoDeTenencia)) begin
	UPDATE tb_Edificios
	SET TipoTenencia = (SELECT idTipoDeTenencia from inserted)
	WHERE TipoTenencia in (SELECT idTipoDeTenencia from deleted)
end
GO
ALTER TABLE [dbo].[tb_TiposDeTenencia] ADD CONSTRAINT [PK_tb_TiposDeTenencia] PRIMARY KEY NONCLUSTERED  ([idTipoDeTenencia]) ON [PRIMARY]
GO
